package controleabastecimento2.activies;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import controleabastecimento2.model.Veiculo;


public class CarroListAdapter extends BaseAdapter {

	private Context context;
	private List<Veiculo> lista;
	
	public CarroListAdapter(Context ctx, List<Veiculo> lista){
		this.context = ctx;
		this.lista = lista;
	}

	public int getCount() {
		return lista.size();
	}

	public Object getItem(int position) {
		return lista.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent){
		Veiculo v = lista.get(position);
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = inflater.inflate(R.layout.veiculo_pesquisa, null);

		TextView veiculo = (TextView) view.findViewById(R.id.tvvVeiculo);
		veiculo.setText(v.getModelo().toString());
		
		TextView placa = (TextView) view.findViewById(R.id.tvvPlaca);
		placa.setText(v.getPlaca().toString());

		return view;
	}
}